﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Threading;
using System.Web;
using System.Web.Mvc;

namespace VVA.Website.UI.Helper
{
    public class BaseController : Controller
    {
        #region Property

        public string Culture
        {
            get { return this.RouteData.Values["culture"].ToString(); }
        }

        #endregion

        #region Method

        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (filterContext.RouteData.Values["culture"] != null &&
                   !string.IsNullOrWhiteSpace(filterContext.RouteData.Values["culture"].ToString()))
            {
                // set the culture from the route data (url)
                var lang = filterContext.RouteData.Values["culture"].ToString();
                Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(lang);
            }

            base.OnActionExecuting(filterContext);
        }

        #endregion
    }
}